<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var findNumberOfLIS = function (nums) {
        let dp = new Array(nums.length + 1).fill(1)
        let count = new Array(nums.length + 1).fill(1)
        let sum = 0
        dp[0] = count[0] = 0
        for (let i = 2; i < dp.length; i++) {
          for (let j = 1; j < i; j++) {
            if (nums[i - 1] > nums[j - 1]) {
              //尾序列更大，判断当前子序列长度计算个数
              if (dp[i] < dp[j] + 1) {
                dp[i] = dp[j] + 1
                count[i] = count[j]
              } else if (dp[i] == dp[j] + 1) {
                count[i] += count[j]
              }
            }
          }
        }
        let max = Math.max(...dp)
        for (let i = 0; i < dp.length; i++) {
          if (dp[i] == max) {
            sum += count[i]
          }
        }
        return sum
      }
    </script>
  </body>
</html>
